﻿@using Wabo.Web.Areas.Manager.ViewModels.User
@using PagedList.Mvc; 
@using PagedList; 

@model UserMessagesViewModel

@{
    ViewBag.Title = Messages.HeadingUserMessagesList;
    var ActiveMailBox = "";        
}
<div class="">
    <div class="btn-group pull-left">
        <h3>@Messages.HeadingUserMessagesList </h3>
    </div>

        <div class="btn-group pull-right">
            <a class="btn dropdown-toggle" data-toggle="dropdown">@Model.CurrentMailBoxTitle<span class="caret"></span></a> 
            <ul class="dropdown-menu">
                <li><a href="@Url.Action("MailBox","User",new{id=0})">@Messages.DISP_AllMessages</a></li>
                <li><a href="@Url.Action("MailBox","User",new{id=1})">@Messages.DISP_UnreadMessages</a></li>
                <li><a href="@Url.Action("MailBox","User",new{id=2})">@Messages.DISP_SentMessages</a></li>
            </ul>
        </div>       
        <div class="btn-group pull-right">
            <a class="btn" href="@Url.Action("Compose","User")">
                <i class=" icon-pencil"></i>@Messages.ComposeMessage
            </a>        
        </div>
   
</div>

<table class="table">
    <thead>
        <tr>
            <th>@Messages.DISP_MessageTitle</th>
            <th>
                @if (Model.CurrentMailBox == 0 || Model.CurrentMailBox == 1)
                {
                    @Messages.DISP_FromUser
                }
                else
                {
                    @Messages.DISP_ToUser
                }
            </th>
            <th class="span2">@Messages.DISP_Date</th>
            <th class="span2">                
            </th>                        
        </tr>        
    </thead>
    @foreach (Message item in Model.Messages)
    {
        var titleClass = item.is_read ? "muted" : "";       
        <tr>
            <td>
                <p class="@titleClass">
                @item.message_title
                </p>                           
            </td>
            <td class="span2">
                @if (Model.CurrentMailBox == 0 || Model.CurrentMailBox == 1)
                {
                    @item.FromUser.username
                }
                else
                {
                    @item.ToUser.username
                }
            </td>
            <td class="span2">
                @item.send_date.ToString("dd/MM/yyyy HH:mm") 
            </td>
            <td class="span2">   
                @if (Model.CurrentMailBox == 0 || Model.CurrentMailBox == 1)
                {                         
                <a class="btn btn-mini btn-success pull-right" href="@Url.Action("Compose", "User", new { item.id })" ><i class="icon-bullhorn icon-white"></i>@Messages.DISP_Reply</a>
                }
                <a class="btn btn-mini btn-success pull-right" href="@Url.Action("ReadMessage", "User", new { item.id })" ><i class="icon-eye-open icon-white"></i>@Messages.DISP_ViewMessage</a>
            </td>

        </tr>
    }
</table>

<div class="pagination-centered">
    @Html.PagedListPager( (IPagedList)Model.Messages, page => Url.Action("MailBox", "User",new { id = Model.CurrentMailBox, page=page }) ,(PagedListRenderOptions)ViewBag.PagerRenderOptions)        
</div>
